package me.helong.videolive;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
@EnableWebSocket
@RestController
public class VideoLiveApplication {
    @Value("${videolive.play-uri}")
    private String playUri;

    public static void main(String[] args) {
        SpringApplication.run(VideoLiveApplication.class, args);
    }

    @GetMapping("/loadPlayUrl")
    public Map<String, Object> loadPlayUrl(@RequestParam String liveChannel) {
        Map<String, Object> result = new HashMap<>();
        result.put("flv", playUri + liveChannel + ".flv");
        result.put("m3u8", playUri + liveChannel + ".m3u8");
        return result;
    }
}
